package chapter06.join;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * alt + mouse click the movie
 */
public class JoinBean implements Writable {
    private String o_id;    // 订单编号
    private String p_id;    // 产品编号
    private int p_amount;   // 产品数量
    private String p_name;  // 产品名称
    private String flag;    // 表的标记

    // 空参构造
    public JoinBean() {
    }

    public JoinBean(String o_id, String p_id, int p_amount, String p_name, String flag) {
        this.o_id = o_id;
        this.p_id = p_id;
        this.p_amount = p_amount;
        this.p_name = p_name;
        this.flag = flag;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(o_id);
        dataOutput.writeUTF(p_id);
        dataOutput.writeInt(p_amount);
        dataOutput.writeUTF(p_name);
        dataOutput.writeUTF(flag);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        o_id = dataInput.readUTF();
        p_id = dataInput.readUTF();
        p_amount = dataInput.readInt();
        p_name = dataInput.readUTF();
        flag = dataInput.readUTF();
    }

    @Override
    public String toString() {
        return o_id + '\t' + p_amount + '\t' + p_amount;
    }

    public String getO_id() {
        return o_id;
    }

    public void setO_id(String o_id) {
        this.o_id = o_id;
    }

    public String getP_id() {
        return p_id;
    }

    public void setP_id(String p_id) {
        this.p_id = p_id;
    }

    public int getP_amount() {
        return p_amount;
    }

    public void setP_amount(int p_amount) {
        this.p_amount = p_amount;
    }

    public String getP_name() {
        return p_name;
    }

    public void setP_name(String p_name) {
        this.p_name = p_name;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }
}
